package com.ruoyi.radar.common;

import cn.hutool.http.HttpRequest;
import cn.hutool.http.HttpResponse;
import cn.hutool.http.HttpUtil;
import com.alibaba.fastjson2.JSONObject;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

@Component
public class CommonMethod {

    @Value("${url.gansu}")
    private String url;

    public Object getToken(){
        HttpRequest request = HttpUtil.createPost(url);

        request.form("action", "login");//待定卡号
        request.form("username", "1");//待定数据类型
        request.form("pwd", "111111");;

        HttpResponse response = request.execute();

        int statusCode = response.getStatus();
        String body = response.body();
        JSONObject jsonObject = JSONObject.parseObject(body);
        Object token = jsonObject.get("token");

        return token;
    }


}
